﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;

namespace Bordspil.Models
{
    public class AppRepository : IAppRepository
    {
        private AppDataContext m_db = new AppDataContext();
        private UsersContext u_db = new UsersContext();

        public IEnumerable<GameInstance> GetGames() //skilar ollum leikja tilvikum
        {
            return m_db.GameInstance;
        }

        public IEnumerable<Games> GetAllGames() //skilar ollum leikjum sem eru i bodi
        {
            return m_db.Games;
        }

        public IEnumerable<UserProfile> GetAllUsers()
        {
            return u_db.UserProfiles;
        }

        public void AddGame(GameInstance g) //ser um ad baeta vid leik i gagnagrun (teas nyju instancei)
        {
            m_db.GameInstance.Add(g);
        }

        public void Save()
        {
            m_db.SaveChanges();
        }

        public IEnumerable<GameRanking> GetAllGameRankings()
        {
            return m_db.GameRanking;
        }


        public void AddGameRating(GameRanking g)
        {
            m_db.GameRanking.Add(g);
        }

        public IEnumerable<PlayerList> GetPlayerList()
        {
            return m_db.PlayerList;
        }

        public void AddToPlayerList(PlayerList p)
        {
            m_db.PlayerList.Add(p);
        }

        public IEnumerable<Highscore> GetAllHighscore()
        {
            return m_db.Highscore;
        }
    }
}